﻿#include "robotsystemsimulator.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
#include "systemjournalwid.h"
#include "pipelinemanagerwid.h"
#include "systemstatewid.h"
#include "pathexcutewid.h"
#include "robotinfowid.h"
#include "stackplatewid.h"
#include "platestackinfowid.h"
#include "safetycomponent.h"
#include "unstackplatewid.h"



RobotSystemSimulator::RobotSystemSimulator(QWidget* parent)
	: QWidget(parent)
{
	ui.setupUi(this);
	setFixedHeight(800);
	//setFixedWidth(1200);
	setWindowIconText("机械手上位机软件");
	setWindowTitle("机械手上位机软件");
	QVBoxLayout* All = new QVBoxLayout(this);
	QHBoxLayout* H = new QHBoxLayout();
	auto system = new SystemStateWid();
	All->addWidget(system);
	All->addLayout(H);
	this->setLayout(All);

	QVBoxLayout* v1 = new QVBoxLayout();
	v1->SetMaximumSize;
	auto pipe = new PipelineManagerWid();
	v1->addWidget(pipe);
	auto rob = new RobotInfoWid(this);
	v1->addWidget(rob);
	auto path = new PathExcuteWid();
	v1->addWidget(path);
	//QSpacerItem *v1S = new 
	//v1->addStretch(0);
	H->addLayout(v1);

	QVBoxLayout* v5 = new QVBoxLayout();
	auto unstackPlate = new UnstackPlateWid(this);
	if (unstackPlate->Init()) {
		v5->addWidget(unstackPlate);
	} else {
		unstackPlate->deleteLater();
	}
	v5->addStretch(0);
	H->addLayout(v5);
	QVBoxLayout* v4 = new QVBoxLayout();
	auto stackplate = new StackPlateWid();
	if (stackplate->Init()) {
		v4->addWidget(stackplate);
	} else {
		delete stackplate;
	}

	auto platestack = new PlateStackInfoWid(this);
	if (platestack->Init()) {
		v4->addWidget(platestack);
	} else {
		platestack->deleteLater();
	}

	auto safe = new SafetyComponent(this);
	if (safe->Init()) {
		v4->addWidget(safe);
	} else {
		safe->deleteLater();
	}
	v4->addStretch(0);
	H->addLayout(v4);

	//QVBoxLayout* v3 = new QVBoxLayout();
	//auto rob = new RobotInfoWid(this);
	//v3->addWidget(rob);
	//v3->addStretch(0);
	//H->addLayout(v3);

	QVBoxLayout* v2 = new QVBoxLayout();
	auto journal = new SystemJournalWid();
	v2->addWidget(journal);
	v2->addStretch(0);
	H->addLayout(v2);
	//H->addWidget(journal);
}

RobotSystemSimulator::~RobotSystemSimulator()
{}
